<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android,Realm," />





  <link rel="alternate" href="/atom.xml" title="GrantonZhuang's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="继续上一篇的内容，这篇文章主要讲 Realm 的工作方式。">
<meta property="og:type" content="article">
<meta property="og:title" content="Realm初步实践２">
<meta property="og:url" content="https://grantonzhuang.github.io/2016/05/14/Realm初步实践 2 /index.html">
<meta property="og:site_name" content="GrantonZhuang's Blog">
<meta property="og:description" content="继续上一篇的内容，这篇文章主要讲 Realm 的工作方式。">
<meta property="og:updated_time" content="2016-07-29T13:56:02.584Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Realm初步实践２">
<meta name="twitter:description" content="继续上一篇的内容，这篇文章主要讲 Realm 的工作方式。">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="https://grantonzhuang.github.io/2016/05/14/Realm初步实践 2 /"/>

  <title> Realm初步实践２ | GrantonZhuang's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">GrantonZhuang's Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/index.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Realm初步实践２
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-05-14T15:59:12+08:00" content="2016-05-14">
              2016-05-14
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>继续上一篇的内容，这篇文章主要讲 Realm 的工作方式。</p>
<a id="more"></a>
<h2 id="编译时的工作，生成-ProxyInterface-和-Proxy"><a href="#编译时的工作，生成-ProxyInterface-和-Proxy" class="headerlink" title="编译时的工作，生成 ProxyInterface 和 Proxy"></a>编译时的工作，生成 ProxyInterface 和 Proxy</h2><p>既然在工程的 gradle 文件中声明了插件和编译路径</p>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">apply plugin: <span class="string">'realm-android'</span></div></pre></td></tr></table></figure>
<figure class="highlight gradle"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">classpath</span> <span class="string">"io.realm:realm-gradle-plugin:0.88.3"</span></div></pre></td></tr></table></figure>
<p>那么很明显，Realm 是在编译时候做了工作的，我们可以在 <code>app/build/generated/source/apt/debug</code> 中找到痕迹。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">➜  debug  <span class="built_in">pwd</span></div><div class="line">/path/to/project/app/build/generated/<span class="built_in">source</span>/apt/debug</div><div class="line">➜  debug  tree</div><div class="line">.</div><div class="line">└── io</div><div class="line">    └── realm</div><div class="line">        ├── DefaultRealmModule.java</div><div class="line">        ├── DefaultRealmModuleMediator.java</div><div class="line">        ├── PersonRealmProxyInterface.java</div><div class="line">        ├── PersonRealmProxy.java</div></pre></td></tr></table></figure>
<p>毫无疑问，<code>PersonRealmProxyInterface.java</code> 和 <code>PersonRealmProxy.java</code> 是 Realm 在编译时生成的文件。</p>
<h2 id="对-ProxyInterface-和-Proxy-进行分析"><a href="#对-ProxyInterface-和-Proxy-进行分析" class="headerlink" title="对 ProxyInterface 和 Proxy 进行分析"></a>对 ProxyInterface 和 Proxy 进行分析</h2><h3 id="ProxyInterface"><a href="#ProxyInterface" class="headerlink" title="ProxyInterface"></a>ProxyInterface</h3><p><code>PersonRealmProxyInterface</code> 是接口的声明，包含了 get 方法和 set 方法。这里的 get 方法和 set 方法代理了对应 model 的 get 方法和 set 方法，稍后会给出说明。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">PersonRealmProxyInterface</span> </span>&#123;</div><div class="line">    <span class="keyword">public</span> <span class="keyword">int</span> realmGet$id();</div><div class="line">    <span class="keyword">public</span> <span class="keyword">void</span> realmSet$id(<span class="keyword">int</span> value);</div><div class="line">    <span class="keyword">public</span> String realmGet$name();</div><div class="line">    <span class="keyword">public</span> <span class="keyword">void</span> realmSet$name(String value);</div><div class="line">    <span class="keyword">public</span> <span class="keyword">int</span> realmGet$age();</div><div class="line">    <span class="keyword">public</span> <span class="keyword">void</span> realmSet$age(<span class="keyword">int</span> value);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="Proxy"><a href="#Proxy" class="headerlink" title="Proxy"></a>Proxy</h3><p><code>PersonRealmProxy</code> 是接口的实现，同时实现了很多通用的方法，Realm 对象会在操作 Model 的时候，调用到这些方法。</p>
<ul>
<li>createOrUpdateUsingJsonObject()</li>
<li>createUsingJsonStream()</li>
<li>copyOrUpdate()</li>
<li>copy()</li>
<li>createDetachedCopy()</li>
<li>…more</li>
</ul>
<p><code>PersonRealmProxy.java</code> 的声明：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">PersonRealmProxy</span> <span class="keyword">extends</span> <span class="title">Person</span></span></div><div class="line">    <span class="keyword">implements</span> <span class="title">RealmObjectProxy</span>, <span class="title">PersonRealmProxyInterface</span> &#123;</div><div class="line">    <span class="comment">// ...</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>这个类继承了 <code>Person</code>，并且实现了动态生成的 <code>PersonRealmProxyInterface.java</code> 接口和这个接口代理的 set 方法和 get 方法。</p>
<p>而 另外一个实现的接口，<code>RealmObjectProxy.java</code> 是一个空接口，用来更方便地标示这个类是 Realm 在编译时候产生的，当然，在 Java 8 的环境下，可以将通用的静态方法放在这个空接口中。</p>
<p>空接口在这里的应用也给了我们一点启示，</p>
<blockquote>
<p>如在 Android 中里，如果是遵循标准的 ActionBar 开发的二级页面，一般会把 ActionBar 的左上角设置为返回的箭头，这里给出一个思路。</p>
</blockquote>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">SecondPage</span> </span>&#123;</div><div class="line">    <span class="comment">// empty interface</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">BaseActivity</span> <span class="keyword">extends</span> <span class="title">Activity</span> </span>&#123;</div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">protected</span> <span class="keyword">void</span> <span class="title">onCreate</span><span class="params">(Bundle savedInstanceState)</span> </span>&#123;</div><div class="line">    	<span class="comment">// ... other init opts</span></div><div class="line">        <span class="keyword">if</span> (<span class="keyword">this</span> <span class="keyword">instanceof</span> SecondPage) &#123;</div><div class="line">            setActionBarBackArrow();</div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>这样子，只要是二级页面，我们只需要实现 <code>SecondPage.java</code> 这个空接口就行了。</p>
<h2 id="Model-和-ModelRealmProxy-之间的调用"><a href="#Model-和-ModelRealmProxy-之间的调用" class="headerlink" title="Model 和 ModelRealmProxy 之间的调用"></a>Model 和 ModelRealmProxy 之间的调用</h2><p>以 createObject() 方法为例，分析 Realm 操作 Model 的时候，具体的调用过程。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"> <span class="keyword">public</span> &lt;E extends RealmObject&gt; <span class="function">E <span class="title">createObject</span><span class="params">(Class&lt;E&gt; clazz)</span> </span>&#123;</div><div class="line">    checkIfValid();</div><div class="line">    <span class="comment">// look here</span></div><div class="line">    Table table = getTable(clazz);</div><div class="line">    <span class="keyword">long</span> rowIndex = table.addEmptyRow();</div><div class="line">    <span class="keyword">return</span> get(clazz, rowIndex);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>第一行是检查是否合法，第二行是将对 Person 操作转换成 PersonRealmProxy 的重要操作。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"> <span class="meta">@Deprecated</span></div><div class="line"><span class="function"><span class="keyword">public</span> Table <span class="title">getTable</span><span class="params">(Class&lt;? extends RealmObject&gt; clazz)</span> </span>&#123;</div><div class="line">    Table table = classToTable.get(clazz);</div><div class="line">    <span class="keyword">if</span> (table == <span class="keyword">null</span>) &#123;</div><div class="line">        clazz = Util.getOriginalModelClass(clazz);</div><div class="line">        <span class="comment">// look here</span></div><div class="line">        table = sharedGroupManager.getTable(configuration.getSchemaMediator().getTableName(clazz));</div><div class="line">        classToTable.put(clazz, table);</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> table;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>其中<code>configuration.getSchemaMediator().getTableName(clazz)</code> 是关键部分，这里的 SchemaMediator 是一个重要角色，如果不知道，就得先看看基础使用啦。</p>
<p>SchemaMediator 是一个 abstract 类，Realm 在编译的时候给出了默认实现。</p>
<p><code>DefaultRealmModuleMediator.java</code></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Override</span></div><div class="line"><span class="function"><span class="keyword">public</span> String <span class="title">getTableName</span><span class="params">(Class&lt;? extends RealmObject&gt; clazz)</span> </span>&#123;</div><div class="line">    checkClass(clazz);</div><div class="line"></div><div class="line">	<span class="comment">// look here</span></div><div class="line">    <span class="keyword">if</span> (clazz.equals(Person.class)) &#123;</div><div class="line">        <span class="keyword">return</span> PersonRealmProxy.getTableName();</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">throw</span> getMissingProxyClassException(clazz);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>这里的 getTable() 方法，直接就将 Person 和 PersonRealmProxy 对应起来了。</p>
<p>再回来看 createObject() 方法，这里返回的是 get(clazz, rowIndex)</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"> <span class="keyword">public</span> &lt;E extends RealmObject&gt; <span class="function">E <span class="title">createObject</span><span class="params">(Class&lt;E&gt; clazz)</span> </span>&#123;</div><div class="line">    checkIfValid();</div><div class="line">    Table table = getTable(clazz);</div><div class="line">    <span class="keyword">long</span> rowIndex = table.addEmptyRow();</div><div class="line">    <span class="comment">// look here</span></div><div class="line">    <span class="keyword">return</span> get(clazz, rowIndex);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>来看这个 get(clazz, rowIndex) 方法</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">&lt;E extends RealmObject&gt; <span class="function">E <span class="title">get</span><span class="params">(Class&lt;E&gt; clazz, <span class="keyword">long</span> rowIndex)</span> </span>&#123;</div><div class="line">    Table table = schema.getTable(clazz);</div><div class="line">    UncheckedRow row = table.getUncheckedRow(rowIndex);</div><div class="line">    <span class="comment">// look here</span></div><div class="line">    E result = configuration.getSchemaMediator().newInstance(clazz, schema.getColumnInfo(clazz));</div><div class="line">    result.row = row;</div><div class="line">    result.realm = <span class="keyword">this</span>;</div><div class="line">    result.setTableVersion();</div><div class="line">    <span class="keyword">if</span> (handlerController != <span class="keyword">null</span>) &#123;</div><div class="line">        handlerController.addToRealmObjects(result);</div><div class="line">    &#125;</div><div class="line">    <span class="keyword">return</span> result;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>同样是 SchemaMediator 类的默认实现 <code>DefaultRealmModuleMediator.java</code>，我们看 <code>newInstance()</code> 方法:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="meta">@Override</span></div><div class="line"><span class="keyword">public</span> &lt;E extends RealmObject&gt; <span class="function">E <span class="title">newInstance</span><span class="params">(Class&lt;E&gt; clazz, ColumnInfo columnInfo)</span> </span>&#123;</div><div class="line">    checkClass(clazz);</div><div class="line"></div><div class="line">    <span class="keyword">if</span> (clazz.equals(Person.class)) &#123;</div><div class="line">        <span class="keyword">return</span> clazz.cast(<span class="keyword">new</span> PersonRealmProxy(columnInfo));</div><div class="line">    &#125; <span class="keyword">else</span> &#123;</div><div class="line">        <span class="keyword">throw</span> getMissingProxyClassException(clazz);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>所以，Realm 以 Person.class 为参数创建实例的时候，返回的时候都是对应的 Proxy 类的实例。</p>
<p>所以，Realm 在整个操作 Model 的过程中，都使用了 Model 的 Proxy 类，这样子最大程度的减少了对 Model 代码的入侵，只需要继承 RealmObject，即可完成所有的操作，一切都在编译时产生，也不会影响运行时的效率。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag">#Android</a>
          
            <a href="/tags/Realm/" rel="tag">#Realm</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/05/08/Realm初步实践１/" rel="next" title="Realm初步实践１">
                <i class="fa fa-chevron-left"></i> Realm初步实践１
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/05/22/Android-动态加载入门/" rel="prev" title="Android-动态加载入门">
                Android-动态加载入门 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://ww1.sinaimg.cn/mw690/6e8939a6gw1f3g1u1mc6lj20hs0hsmxf.jpg"
               alt="Granton Zhuang" />
          <p class="site-author-name" itemprop="name">Granton Zhuang</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives/index.html">
              <span class="site-state-item-count">26</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">11</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#编译时的工作，生成-ProxyInterface-和-Proxy"><span class="nav-number">1.</span> <span class="nav-text">编译时的工作，生成 ProxyInterface 和 Proxy</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#对-ProxyInterface-和-Proxy-进行分析"><span class="nav-number">2.</span> <span class="nav-text">对 ProxyInterface 和 Proxy 进行分析</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#ProxyInterface"><span class="nav-number">2.1.</span> <span class="nav-text">ProxyInterface</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Proxy"><span class="nav-number">2.2.</span> <span class="nav-text">Proxy</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Model-和-ModelRealmProxy-之间的调用"><span class="nav-number">3.</span> <span class="nav-text">Model 和 ModelRealmProxy 之间的调用</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Granton Zhuang</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  




  
  

  

  

  

</body>
</html>
